﻿using Sdg.Domain.Services;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sdg.Domain.BizObj
{
    public class TableColumn
    {
        private IColumnDataGenerator _dataGenerator;
        private string _name;
        private Type _dbType;
        
        private bool _isIdentity;

        public TableColumn(string name, Type dbType, IColumnDataGenerator dataGen)
        {
            _dataGenerator = dataGen;
            _name = name;
            _dbType = dbType;
        }

        public bool IsIdentity { get { return _isIdentity; } }

        public string Name { get { return _name; } }
        public Type ColumnType { get { return _dbType; } }

        public IColumnDataGenerator DataGenerator
        {
            get
            {
                if (_dataGenerator == null)
                    throw new NullReferenceException("Отсутствует генератор данных для Поля" + Name);

                return _dataGenerator;
            }
        }

        public override string ToString()
        {
            return Name + " " + ColumnType.ToString();
        }
    }
}
